package com.yilifang.dao.master;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * Created by zhuan on 2018-09-14.
 */
@Mapper
public interface MasterDirectSqlMapper {

    @Select("SELECT *\n" +
            "  FROM (SELECT tt.*, ROWNUM AS rowno\n" +
            "          FROM (   select \n" +
            "                   t.vannouncetype VannounceType ,\n" +
            "                   t.vprojname VannounceTitle,\n" +
            "                   t.vhtmlcontentforwx VannounceContent, \n" +
            "                   t.dbilldate ReleaseDate\n" +
            "                   from zbdl_biding_announce t \n" +
            "                   where t.vannouncetype in(0,1,3)\n" +
            "                   and vbillstatus = 1\n" +
            "                   and dr = 0\n" +
            "                   order by t.dbilldate desc) tt\n" +
            "         WHERE ROWNUM <= #{page}*#{size}) table_alias\n" +
            " WHERE table_alias.rowno >= (#{page}-1)*#{size}")
    List<Map<String, Object>> selectZbdlAnnounce(@Param("page") Integer page, @Param("size") Integer size);
    @Select("SELECT *\n" +
            "  FROM (SELECT tt.*, ROWNUM AS rowno\n" +
            "          FROM (   select \n" +
            "                   t.vprojname VannounceTitle,\n" +
            "                   t.PK_BIDING_ANNOUNCE id,\n" +
            "                   t.dbilldate ReleaseDate\n" +
            "                   from zbdl_biding_announce t \n" +
            "                   where t.vannouncetype = #{vannouncetype}\n" +
            "                   and vbillstatus = 1\n" +
            "                   and dr = 0\n" +
            "                   order by t.dbilldate desc) tt\n" +
            "         WHERE ROWNUM <= #{page}*#{size}) table_alias\n" +
            " WHERE table_alias.rowno >= (#{page}-1)*#{size}")
    List<Map<String, Object>> selectZbdlAnnounceList(@Param("page") Integer page, @Param("size") Integer size,@Param("vannouncetype") String vannouncetype);

    @Select("select \n" +
            "   t.vprojname VannounceTitle, \n" +
            "   t.PK_BIDING_ANNOUNCE id, \n" +
            "   t.dbilldate ReleaseDate,\n" +
            "   t.vhtmlcontentforwx VannounceContent\n" +
            "   from zbdl_biding_announce t  \n" +
            "   where t.PK_BIDING_ANNOUNCE = #{id}")
    Map<String, Object> selectZbdlAnnounceHtmlById(@Param("id") String id);

    @Select("SELECT count(*) zbdlAnnounceCount FROM zbdl_biding_announce" +
            "  where vannouncetype = #{vannouncetype}" +
            "    and vbillstatus = 1 and dr = 0")
    Map<String, Object> selectZbdlAnnounceCount(@Param("vannouncetype") String vannouncetype);
}
